Expressions run as real JS code. Write simple math or full multi-line logic.
10 + stat_carpentry * 2
max(1, 800 * 0.9^stat_carpentry)
^
**
floor(pop_Builder / 3)
Use return to return a value from multi-line code:
return
let base = 800; let reduction = 0.9 ** stat_carpentry; return max(1, base * reduction);
if (tech_Iron_Working) return 50; return 120;
Stats use the stat_ prefix: stat_carpentry, stat_alchemy
stat_
stat_carpentry
stat_alchemy
build_Barracks
pop_Warrior
tech_Iron_Working
res_Gold
Spaces in names become underscores: Iron Working → tech_Iron_Working
Iron Working
military
military_count
max(a, b)
min(a, b)
round(x)
floor(x)
ceil(x)
abs(x)
clamp(v, lo, hi)
rand
Build / research time that scales down with a stat:
Starts at 800 ticks, shrinks by 10% per carpentry level, never below 1.
Cost that scales with multiple factors:
max(1, 800 * 0.9^stat_carpentry * 0.85^build_Sawmill)
Stacks two separate diminishing curves — both carpentry stat and Sawmill count reduce cost.
Flat bonus per pop:
pop_Worker * 3
Each Worker adds 3 to the result (e.g. a resource modifier).
Unlock gate — different value based on tech:
tech_Iron_Working ? 50 : 120
Returns 50 if Iron Working is researched, 120 otherwise. Good for build times.
Random loot drop (effect delta):
round(rand * 10) + 5
Gives 5–15 of a resource, randomly each time the action fires.
Clamp a scaling value:
clamp(stat_carpentry * 5, 10, 100)
Scales with carpentry but is always between 10 and 100.
Multi-line: tiered output based on stat level:
if (stat_carpentry >= 10) return 200; if (stat_carpentry >= 5) return 100; return 40;
Returns different values depending on thresholds. No need for nested ternaries.
Multi-line: complex cost reduction:
let base = 500; let discount = build_Lumberyard * 0.05; let reduced = base * (1 - discount); return max(10, round(reduced));
Each Lumberyard gives a 5% discount, rounded, floored at 10.
Tag-based: reward scales with military presence:
military_count * 2 + 10
Uses the total count of all military-tagged node instances.